Set argv0= to allow multi-executable binaries#11
Set argv0= to allow multi-executable binaries#11matthewbauer wants to merge 1 commit intosolidsnack:masterfrom
Conversation
Some binaries use $0 sniffing to determine what mode to use. So, we
want to propagate the argv0 we are using so we can use these programs.
A good example is “coreutils” which uses this method:
$ tree /nix/store/...-coreutils-8.31
.
├── bin
│ ├── [ -> coreutils
│ ├── b2sum -> coreutils
│ ├── base32 -> coreutils
│ ├── base64 -> coreutils
│ ├── basename -> coreutils
│ ├── basenc -> coreutils
│ ├── cat -> coreutils
│ ├── chcon -> coreutils
│ ├── chgrp -> coreutils
│ ├── chmod -> coreutils
│ ├── chown -> coreutils
│ ├── chroot -> coreutils
│ ├── cksum -> coreutils
│ ├── comm -> coreutils
│ ├── coreutils
│ ├── cp -> coreutils
│ ├── csplit -> coreutils
│ ├── cut -> coreutils
│ ├── date -> coreutils
│ ├── dd -> coreutils
│ ├── df -> coreutils
│ ├── dir -> coreutils
│ ├── dircolors -> coreutils
│ ├── dirname -> coreutils
│ ├── du -> coreutils
│ ├── echo -> coreutils
│ ├── env -> coreutils
│ ├── expand -> coreutils
│ ├── expr -> coreutils
│ ├── factor -> coreutils
│ ├── false -> coreutils
│ ├── fmt -> coreutils
│ ├── fold -> coreutils
│ ├── groups -> coreutils
│ ├── head -> coreutils
│ ├── hostid -> coreutils
│ ├── id -> coreutils
│ ├── install -> coreutils
│ ├── join -> coreutils
│ ├── kill -> coreutils
│ ├── link -> coreutils
│ ├── ln -> coreutils
│ ├── logname -> coreutils
│ ├── ls -> coreutils
│ ├── md5sum -> coreutils
│ ├── mkdir -> coreutils
│ ├── mkfifo -> coreutils
│ ├── mknod -> coreutils
│ ├── mktemp -> coreutils
│ ├── mv -> coreutils
│ ├── nice -> coreutils
│ ├── nl -> coreutils
│ ├── nohup -> coreutils
│ ├── nproc -> coreutils
│ ├── numfmt -> coreutils
│ ├── od -> coreutils
│ ├── paste -> coreutils
│ ├── pathchk -> coreutils
│ ├── pinky -> coreutils
│ ├── pr -> coreutils
│ ├── printenv -> coreutils
│ ├── printf -> coreutils
│ ├── ptx -> coreutils
│ ├── pwd -> coreutils
│ ├── readlink -> coreutils
│ ├── realpath -> coreutils
│ ├── rm -> coreutils
│ ├── rmdir -> coreutils
│ ├── runcon -> coreutils
│ ├── seq -> coreutils
│ ├── sha1sum -> coreutils
│ ├── sha224sum -> coreutils
│ ├── sha256sum -> coreutils
│ ├── sha384sum -> coreutils
│ ├── sha512sum -> coreutils
│ ├── shred -> coreutils
│ ├── shuf -> coreutils
│ ├── sleep -> coreutils
│ ├── sort -> coreutils
│ ├── split -> coreutils
│ ├── stat -> coreutils
│ ├── stdbuf -> coreutils
│ ├── stty -> coreutils
│ ├── sum -> coreutils
│ ├── sync -> coreutils
│ ├── tac -> coreutils
│ ├── tail -> coreutils
│ ├── tee -> coreutils
│ ├── test -> coreutils
│ ├── timeout -> coreutils
│ ├── touch -> coreutils
│ ├── tr -> coreutils
│ ├── true -> coreutils
│ ├── truncate -> coreutils
│ ├── tsort -> coreutils
│ ├── tty -> coreutils
│ ├── uname -> coreutils
│ ├── unexpand -> coreutils
│ ├── uniq -> coreutils
│ ├── unlink -> coreutils
│ ├── uptime -> coreutils
│ ├── users -> coreutils
│ ├── vdir -> coreutils
│ ├── wc -> coreutils
│ ├── who -> coreutils
│ ├── whoami -> coreutils
│ └── yes -> coreutils
└── libexec
└── coreutils
└── libstdbuf.so
3 directories, 108 files
|
Thanks for making this change. I'm not sure we can use this method -- It sounds like you're not calling including the binary in the tarball and calling it with a script, but rather inlining the binary, using |
Oops didn't consider that! It's definitely good to avoid that.
The binary is still in the tarball. The problem is I don't want to hardcode the binary name into it. So for instance, I would like to be able to make a symlink on the outer arx script so that it propagates to the inner "$0". Here is a good way to show what happens without using I'd like it to show |
582f866 to
b0aa443
Compare
Some binaries use $0 sniffing to determine what mode to use. So, we
want to propagate the argv0 we are using so we can use these programs.
A good example is “coreutils” which uses this method:
$ tree /nix/store/...-coreutils-8.31
.
├── bin
│ ├── [ -> coreutils
│ ├── b2sum -> coreutils
│ ├── base32 -> coreutils
│ ├── base64 -> coreutils
│ ├── basename -> coreutils
│ ├── basenc -> coreutils
│ ├── cat -> coreutils
│ ├── chcon -> coreutils
│ ├── chgrp -> coreutils
│ ├── chmod -> coreutils
│ ├── chown -> coreutils
│ ├── chroot -> coreutils
│ ├── cksum -> coreutils
│ ├── comm -> coreutils
│ ├── coreutils
│ ├── cp -> coreutils
│ ├── csplit -> coreutils
│ ├── cut -> coreutils
│ ├── date -> coreutils
│ ├── dd -> coreutils
│ ├── df -> coreutils
│ ├── dir -> coreutils
│ ├── dircolors -> coreutils
│ ├── dirname -> coreutils
│ ├── du -> coreutils
│ ├── echo -> coreutils
│ ├── env -> coreutils
│ ├── expand -> coreutils
│ ├── expr -> coreutils
│ ├── factor -> coreutils
│ ├── false -> coreutils
│ ├── fmt -> coreutils
│ ├── fold -> coreutils
│ ├── groups -> coreutils
│ ├── head -> coreutils
│ ├── hostid -> coreutils
│ ├── id -> coreutils
│ ├── install -> coreutils
│ ├── join -> coreutils
│ ├── kill -> coreutils
│ ├── link -> coreutils
│ ├── ln -> coreutils
│ ├── logname -> coreutils
│ ├── ls -> coreutils
│ ├── md5sum -> coreutils
│ ├── mkdir -> coreutils
│ ├── mkfifo -> coreutils
│ ├── mknod -> coreutils
│ ├── mktemp -> coreutils
│ ├── mv -> coreutils
│ ├── nice -> coreutils
│ ├── nl -> coreutils
│ ├── nohup -> coreutils
│ ├── nproc -> coreutils
│ ├── numfmt -> coreutils
│ ├── od -> coreutils
│ ├── paste -> coreutils
│ ├── pathchk -> coreutils
│ ├── pinky -> coreutils
│ ├── pr -> coreutils
│ ├── printenv -> coreutils
│ ├── printf -> coreutils
│ ├── ptx -> coreutils
│ ├── pwd -> coreutils
│ ├── readlink -> coreutils
│ ├── realpath -> coreutils
│ ├── rm -> coreutils
│ ├── rmdir -> coreutils
│ ├── runcon -> coreutils
│ ├── seq -> coreutils
│ ├── sha1sum -> coreutils
│ ├── sha224sum -> coreutils
│ ├── sha256sum -> coreutils
│ ├── sha384sum -> coreutils
│ ├── sha512sum -> coreutils
│ ├── shred -> coreutils
│ ├── shuf -> coreutils
│ ├── sleep -> coreutils
│ ├── sort -> coreutils
│ ├── split -> coreutils
│ ├── stat -> coreutils
│ ├── stdbuf -> coreutils
│ ├── stty -> coreutils
│ ├── sum -> coreutils
│ ├── sync -> coreutils
│ ├── tac -> coreutils
│ ├── tail -> coreutils
│ ├── tee -> coreutils
│ ├── test -> coreutils
│ ├── timeout -> coreutils
│ ├── touch -> coreutils
│ ├── tr -> coreutils
│ ├── true -> coreutils
│ ├── truncate -> coreutils
│ ├── tsort -> coreutils
│ ├── tty -> coreutils
│ ├── uname -> coreutils
│ ├── unexpand -> coreutils
│ ├── uniq -> coreutils
│ ├── unlink -> coreutils
│ ├── uptime -> coreutils
│ ├── users -> coreutils
│ ├── vdir -> coreutils
│ ├── wc -> coreutils
│ ├── who -> coreutils
│ ├── whoami -> coreutils
│ └── yes -> coreutils
└── libexec
└── coreutils
└── libstdbuf.so
3 directories, 108 files
It needs argv0 to be set to the real name of the utility. Before it was something like
/tmp/tmpx-20190509T191742Z-4f90c6f0/dat/../run